package com.house.house.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.house.house.dao.HouseRepository;
import com.house.house.dao.OwnerRepository;
import com.house.house.entity.House;

@Service
@Transactional
public class HouseService implements IHouseService{
	
	@Autowired
	private HouseRepository houseRepository;
//	private OwnerRepository ownerRepository;
	@Override
	public void save(House house) {
		houseRepository.save(house);
		
	}
	@Transactional(readOnly = true)
	public House findOne(Long id) {
		House house = houseRepository.findOne(id);
		return house;
	}
	@Transactional(readOnly = true)
	public List<House> findAll() {
		List<House> list = (List<House>) houseRepository.findAll();
		return list;
	}
	@Transactional(readOnly = true)
	public Page<House> findPage(Specification<House> spec, Pageable pageable) {
		
		return houseRepository.findAll(spec, pageable);
	}
	

}
